#include "EditorScriptEngine.hpp"

EditorScriptEngine::EditorScriptEngine(){
    scriptEngine.loadScript("editor.lua");
}

/**
 * Run startup script.
 * @param editor Pointer to calling editor.
 */
void EditorScriptEngine::startup(Scriptable* editor){
    scriptEngine.registerClass(editor);
    scriptEngine.loadFunction("startup");
    scriptEngine.pushScriptable(editor);
    scriptEngine.run(1, 0);
}

/**
 * Run input handling script.
 * @return true if input has been handled, false otherwise.
 */
bool EditorScriptEngine::input(){
    scriptEngine.loadFunction("input");
    scriptEngine.run(0, 1);
    return scriptEngine.getBool();
}

/**
 * Run update script.
 */
void EditorScriptEngine::update(){
    scriptEngine.loadAndRun("update");
}